/* -----------------------------------------------------------------------------
 * PROJECT    : poc
 * FILE       : QuestionInfo.java
 *
 * HISTORY:
 * Date          Author                        Description
 * ----------------------------------------------------------------------------- 
 * Dec 16, 2010  mycodetalks			       Created
 */
package net.entity;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import net.handler.entities.RadioData;
import net.number.util.RandomNumberGenerator;

/**
 * Class description goes here
 */
public class QuestionInfo extends AttemptedQuestion {
	
	private static final long serialVersionUID = 1L;
	
	private Object questionObject; //will be removed later
	private int questionNumber = 1;
	private String operation;
	private int decimalDigits;
	private String htmlQuestion;
	
	public Object getQuestionObject() { 
		return questionObject;
	}
	public void setQuestionObject(Object questionObject) {
		this.questionObject = questionObject;
	}

	public int getQuestionNumber() {
		return questionNumber;
	}
	public void setQuestionNumber(int questionNumber) {
		this.questionNumber = questionNumber;
	}
	public String getOperation() {
		return operation;
	}
	public void setOperation(String operation) {
		this.operation = operation;
	}
	public int getDecimalDigits() {
		return decimalDigits;
	}
	public void setDecimalDigits(int decimalDigits) {
		this.decimalDigits = decimalDigits;
	}
	public String getHtmlQuestion() {
		return htmlQuestion;
	}
	public void setHtmlQuestion(String htmlQuestion) {
		this.htmlQuestion = htmlQuestion;
	}
	public List<RadioData> getRadioAnswerChoices() {
		return this.generateRadioAnswerChoises();
	}
	
	private List<RadioData> generateRadioAnswerChoises() {
		
		List<RadioData> rData = new ArrayList<RadioData>();
		String answer = getAnswer();
		if (this.decimalDigits == 0) {
			@SuppressWarnings("unchecked")
			List<Integer> answerChoices = RandomNumberGenerator.generateInts(answer.trim().length(), 4);
			rData.add(new RadioData(answer, answer));
			for (Integer intger : answerChoices) {
				String value = String.valueOf(intger.intValue());
				if(!value.equals(answer)) {
					RadioData data = new RadioData(value, value);
					rData.add(data);
				}
			}
		}
		else {
			//TODO when the answer has decimal digits, handle accordingly
		}

		Collections.shuffle(rData);
		
		return rData;
	}

} 


